//
//  FactoryMessageCell.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/26.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "FactoryMessageCell.h"

@interface FactoryMessageCell ()

@property (nonatomic, strong) UILabel *statuLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *numberLabel;

@end

@implementation FactoryMessageCell

+ (FactoryMessageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"FactoryMessageCell";
    FactoryMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[FactoryMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = RGB_COLOR(244, 244, 244);
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(10), SCREEN_WIDTH - ScreenX375(32), ScreenX375(144))];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = ScreenX375(4);
    bgView.clipsToBounds = YES;
    [self addSubview:bgView];
    
    self.statuLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(15), ScreenX375(100), ScreenX375(18))];
    self.statuLabel.textColor = REXADECIMALCOLOR(@"#222222");
    self.statuLabel.font = Kfont(16);
    self.statuLabel.text = @"订单已签收";
    [bgView addSubview:self.statuLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(148), ScreenX375(16), ScreenX375(100), ScreenX375(14))];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#ababab");
    self.timeLabel.font = Kfont(12);
    self.timeLabel.text = @"18/11/03";
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    [bgView addSubview:self.timeLabel];
    
    UIView *contentBg = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(48), SCREEN_WIDTH - ScreenX375(64), ScreenX375(80))];
    contentBg.layer.cornerRadius = ScreenX375(6);
    contentBg.backgroundColor = REXADECIMALCOLOR(@"#f4f4f4");
    contentBg.clipsToBounds = YES;
    [bgView addSubview:contentBg];
    
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(80), ScreenX375(80))];
    self.headImage.image = ImageWithName(@"13");
    self.headImage.contentMode = UIViewContentModeScaleAspectFill;
    self.headImage.clipsToBounds = YES;
    [contentBg addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(90), ScreenX375(4), ScreenX375(196), ScreenX375(42))];
    self.nameLabel.text = @"欧美风格连衣裙 时尚潮流首选独一无二的服装设计";
    self.nameLabel.numberOfLines = 0;
    self.nameLabel.font = Kfont(14);
    self.nameLabel.textColor = FONTCOLOR_BLACK;
    [contentBg addSubview:self.nameLabel];
    
    self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(90), ScreenX375(55), ScreenX375(204), ScreenX375(14))];
    self.numberLabel.text = @"运单编号：7058920153334";
    self.numberLabel.font = Kfont(12);
    self.numberLabel.textColor = REXADECIMALCOLOR(@"#888888");
    [contentBg addSubview:self.numberLabel];
}

- (void)setFactoryMessageModel:(FactoryMessageModel *)factoryMessageModel {
    _factoryMessageModel = factoryMessageModel;
    
    self.statuLabel.text = factoryMessageModel.content;
    self.timeLabel.text = [HttpManager getTime:[HttpManager TimeStamp:factoryMessageModel.modifyTime]];
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:factoryMessageModel.proPic] placeholderImage:nil options:SDWebImageRetryFailed];
    self.nameLabel.text = factoryMessageModel.proName;
    self.numberLabel.text = [NSString stringWithFormat:@"运单编号：%@",factoryMessageModel.ordNum];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation FactoryMessageModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id"
                                                                  }];
}


@end
